import java.util.Calendar;

public class CalendarDemo {
	public static void main(String[] args) {
		Calendar calendar = Calendar.getInstance();
		calendar.set(2022, 5, 16, 15, 34, 34);
		Calendar calendar1 = Calendar.getInstance();
		calendar1.set(2021, 5, 16, 15, 34, 34);
		// 比较这两个日期的先后顺序
		// calendar是否在calendar1之后
		System.out.println(calendar.after(calendar1));
		// calendar是否在calendar1之前
		System.out.println(calendar.before(calendar1));
		// 获取时间点的一些数据
		// 年份
		System.out.println(calendar.get(Calendar.YEAR));
		// 月份
		System.out.println(calendar.get(Calendar.MONTH));
		// 日
		System.out.println(calendar.get(Calendar.DATE));
		System.out.println(calendar.get(Calendar.DAY_OF_MONTH));

		// 时
		System.out.println(calendar.get(Calendar.HOUR));
		System.out.println(calendar.get(Calendar.HOUR_OF_DAY));
		// 分
		System.out.println(calendar.get(Calendar.MINUTE));

		// 这一天在这一周的第几天
		// calendar.setFirstDayOfWeek(Calendar.MONDAY);
		System.out.println(calendar.get(Calendar.DAY_OF_WEEK));

		// 这一天在这一年的第几周
		System.out.println(calendar.get(Calendar.DAY_OF_WEEK_IN_MONTH));
		// 这一天在这一年的第几天
		System.out.println(calendar.get(Calendar.DAY_OF_YEAR));

		System.out.println("*******");
		// 这一天在这一周的第几天
		// calendar.setFirstDayOfWeek(Calendar.MONDAY);
		System.out.println(calendar.get(Calendar.DAY_OF_WEEK));

	}

}
